package br.ufpe.cin.sm.nninn.connection;

import java.io.InputStream;
import java.net.ConnectException;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import android.util.Log;

public class Connector {

	public static InputStream connect(String url) throws ConnectException {	
		try {
			HttpClient httpclient = new DefaultHttpClient();
			HttpGet httpGet = new HttpGet(url);
			HttpResponse response = httpclient.execute(httpGet);
			HttpEntity entity = response.getEntity();
			return entity.getContent();	
		} catch (Exception e) {
			Log.e("log_tag", "Error in http connection " + e.toString());
			throw new ConnectException("Connction error");			
		}
	}
}
